package com.tanhua.admin.controller;


import com.itheima.model.domain.UserInfo;
import com.itheima.model.vo.MovementsVo;
import com.itheima.model.vo.PageResult;
import com.tanhua.admin.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class ManagerController {

    @Autowired
    private ManagerService managerService;

    @GetMapping("/users")
    public ResponseEntity users (@RequestParam (defaultValue = "1") Integer page,
                                 @RequestParam(defaultValue = "10") Integer pagesize){
       PageResult pageResult = managerService.users(page,pagesize);
        return ResponseEntity.ok(pageResult);
    }

    //根据id查询
    @GetMapping("/users/{userId}")
    public ResponseEntity findUserInfo(@PathVariable("userId") Long userId) {
       UserInfo userInfo = managerService.findUserInfo(userId);
       return ResponseEntity.ok(userInfo);
    }

    //根据id查询用户视频列表
    @GetMapping("/videos")
    public ResponseEntity findByUserIdVideosList(@RequestParam (defaultValue = "1") Integer page,
                                                 @RequestParam (defaultValue = "10") Integer pagesize,Long uid) {
           PageResult pr = managerService.findByUserIdVideosList(page,pagesize,uid);

           return ResponseEntity.ok(pr);
    }

    //根据id查询分页动态信息
    @GetMapping("/messages")
    public ResponseEntity findByUserIdMovement(@RequestParam (defaultValue = "1") Integer page,
                                               @RequestParam (defaultValue = "10") Integer pagesize,Long uid,
                                               Integer state){
       PageResult pr = managerService.findByUserIdMovement(page,pagesize,state,uid);
       return ResponseEntity.ok(pr);
    }

    //根据id查询分页动态信息
    @GetMapping("/messages/{id}")
    public ResponseEntity findByUserIdMovementInfo(@PathVariable ("id") String userId){
         MovementsVo movementsvo=managerService.findByUserIdMovementInfo(userId);
        return ResponseEntity.ok(movementsvo);
    }
}
